home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1 Issue 2 / PDCD-1 - Issue 02.iso / _utilities / utilities / 003 / _gs / !GS / h / FILE < prev    next >
Text File  |  1991-10-25  |  2KB  |  48 lines

  1. /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* file.h */
  21. /* Common declarations for zfile.c and zfileio.c */
  22. /* Requires stream.h */
  23.  
  24. /* File objects store a pointer to a stream in value.pfile. */
  25. /* A file object is valid if its buffer size is non-zero. */
  26. #define fptr(pref) (pref)->value.pfile
  27. #define make_file(pref,a,s)\
  28.   make_tav(pref,t_file,a,pfile,s)
  29.  
  30. /* The standard files.  0 is %stdin, 1 is %stdout. */
  31. extern stream std_files[];
  32. /* An invalid file. */
  33. extern stream invalid_file_entry;
  34.  
  35. /* Macros for checking file validity */
  36. #define check_file_access(svar,op,acc)\
  37.    {    svar = fptr(op);    /* do first, acc may refer to it */\
  38.     if ( svar == 0 || !(acc) )\
  39.         return e_invalidaccess;\
  40.    }
  41. #define check_file_ref(svar,op,acc)\
  42.    {    if ( !r_has_type(op, t_file) ) return e_typecheck;\
  43.     check_file_access(svar,op,acc);\
  44.    }
  45. #define check_file(svar,op) check_file_ref(svar,op,1)
  46. #define check_read_file(svar,op) check_file_ref(svar,op,!svar->writing)
  47. #define check_write_file(svar,op) check_file_ref(svar,op,svar->writing)
  48.